package com.orkasgb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.orkasgb.entity.OrkasgbRoleEntity;
import com.orkasgb.mapper.OrkasgbRoleMapper;
import com.orkasgb.service.IOrkasgbRoleService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

/**
 * 角色信息表(TOrkasgbRole)表服务实现类
 *
 * @version 1.0.0
 * @since 2024-10-09 11:37:08
 */
@Slf4j
@Service
public class OrkasgbRoleServiceImpl extends ServiceImpl<OrkasgbRoleMapper, OrkasgbRoleEntity> implements IOrkasgbRoleService {

    @Resource
    private OrkasgbRoleMapper orkasgbRoleMapper;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @Override
    public OrkasgbRoleEntity getOrkasgbRole(Serializable id) {
        return this.getBaseMapper().selectById(id);
    }

    /**
     * 通过条件查询多条数据
     *
     * @param orkasgbRoleEntity 实体查询参数
     * @return 数据
     */
    @Override
    public List<OrkasgbRoleEntity> getOrkasgbRoleList(OrkasgbRoleEntity orkasgbRoleEntity) {
        QueryWrapper<OrkasgbRoleEntity> queryWrapper = new QueryWrapper<>(OrkasgbRoleEntity.class);
        return this.getBaseMapper().selectList(queryWrapper);
    }

    /**
     * 通过条件查询多条数据(分页查询)
     *
     * @param orkasgbRoleEntity 查询参数实体
     * @return 数据
     */
    @Override
    public IPage<OrkasgbRoleEntity> getOrkasgbRolePageDataList(OrkasgbRoleEntity orkasgbRoleEntity) {
        LambdaQueryWrapper<OrkasgbRoleEntity> queryWrapper = new LambdaQueryWrapper<>(OrkasgbRoleEntity.class);
        IPage<OrkasgbRoleEntity> page = new Page<>(orkasgbRoleEntity.getCurrent(), orkasgbRoleEntity.getPageSize());
        return this.page(page, queryWrapper);
    }

    /**
     * 新增数据
     *
     * @param orkasgbRoleEntity 实体对象
     * @return 新增结果
     */
    @Override
    public int addOrkasgbRole(OrkasgbRoleEntity orkasgbRoleEntity) {
        return this.getBaseMapper().insert(orkasgbRoleEntity);
    }

    /**
     * 修改数据
     *
     * @param orkasgbRoleEntity 实体对象
     * @return 修改结果
     */
    @Override
    public int updateOrkasgbRole(OrkasgbRoleEntity orkasgbRoleEntity) {
        return this.getBaseMapper().updateById(orkasgbRoleEntity);
    }

    /**
     * 修改或者新增数据
     *
     * @param orkasgbRoleEntityList 实体对象
     * @return 操作结果
     */
    @Override
    public int addOrUpdateOrkasgbRole(List<OrkasgbRoleEntity> orkasgbRoleEntityList) {
        return orkasgbRoleMapper.insertOrUpdateBatch(orkasgbRoleEntityList);
    }

    /**
     * 删除数据
     *
     * @param idList 主键结合
     * @return 删除结果
     */
    @Override
    public int deleteOrkasgbRoleByIds(List<Long> idList) {
        return this.getBaseMapper().deleteByIds(idList);
    }
}

